package actions;

import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import tablemodels.RiskCriterionModel;
import utils.Criterion;


/**
 * 
 * @author dernasherbrezon
 *
 */
public class RiskCriterionFiller extends WizardStep
{
	ArrayList<Criterion> riskCriterions;
	RiskCriterionModel data;
	
	public RiskCriterionFiller(ArrayList<Criterion> riskCriterions)
	{
		this.riskCriterions = riskCriterions;
		
		BoxLayout bl = new BoxLayout(this,BoxLayout.Y_AXIS);
		setLayout(bl);
		
		add(new JLabel("Список критериев важности рисков"));
		
		data = new RiskCriterionModel();
		
		JTable table = new JTable(data);
		table.getTableHeader().setReorderingAllowed(false);
		JScrollPane sp = new JScrollPane(table);
		add(sp);
	}
	
	@Override
	public void checkInputValues() throws Exception
	{
		data.checkCorrectValues();
	}

	@Override
	public void makeActions()
	{
		riskCriterions.clear();
		for(int i=0;i<data.getRowCount();i++)
		{
			riskCriterions.add(new Criterion(i+1));
		}
	}

	@Override
	public void preShow()
	{
	}
}
